package PageNum

import (
	"OnlineRetailers/models"
	"github.com/astaxie/beego/orm"
)

func GetPageNum(s string, o orm.Ormer) (int, error) {
	var count int

	sql := "select count(*) from `" + s + "`"
	err := o.Raw(sql).QueryRow(&count)
	if err != nil {
		return 0, err
	}
	if count/models.AdminPage != 0 {
		count += models.AdminPage
	}
	//fmt.Println(count)
	return count, nil
}
